Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize consumer messages sequences for multiple subjects #4129

Merged
merged 1 commit into from
May 4, 2023

Conversation

Jarema
Copy link
Member

@Jarema Jarema commented May 3, 2023

If consumer with multiple subjects encountered a sequnece of messages in a row from the same subject, it tried to load messages from other subjects in some cases.
This checks for that scenario and optimizes it by early returning.

I added a temporary instrumentation to check for how many times fetching new messages is called, and it seems that it cuts those calls according to assumptions. Though it being internal, it's really hard to show that in test.

Signed-off-by: Tomasz Pietrek tomasz@nats.io

@Jarema Jarema requested a review from a team as a code owner May 3, 2023 20:51
@@ -3295,6 +3295,11 @@ func (o *consumer) getNextMsg() (*jsPubMsg, uint64, error) {
o.updateSkipped(uint64(filter.currentSeq))
}
}

// If we're sure that this filter has continuous sequence of messages, skip looking up other filters.
if filter.currentSeq == nextSeq && sseq == filter.currentSeq && err != ErrStoreEOF {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so nextSeq == sseq?

If consumer with multiple subjects encountered a sequnece
of messages from the same subject, it tried to load messages
from other subjects in some cases.
This checks for that scenario and optimizes it by early returning.

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
@Jarema Jarema force-pushed the jarema-optimize-consumer-sequences branch from 0fe17ef to 7c1c4ea Compare May 4, 2023 14:02
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jarema Jarema merged commit 69fb3db into dev May 4, 2023
@Jarema Jarema deleted the jarema-optimize-consumer-sequences branch May 4, 2023 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants